package web.Roles;

import com.google.gson.Gson;
import entity.RolesBean;
import entity.Roles_PerBean;
import services.RolesServiceAll;
import services.Roles_PerService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/RolesServiceAll")
public class RolesServletAll extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("application/json");
        List<Roles_PerBean> all = new Roles_PerService().all();
        Gson gson = new Gson();
        String json = gson.toJson(all);
        resp.getWriter().println(json);
    }
}
